package cn.sciento.farm.devicemanager.api.jsonrpc.impl;

import cn.sciento.farm.devicemanager.api.jsonrpc.TenantConfigJsonApi;
import cn.sciento.farm.devicemanager.common.constant.ResultConstant;
import cn.sciento.farm.devicemanager.dao.entity.TenantConfig;
import cn.sciento.farm.devicemanager.dao.model.ResponseMessage;
import cn.sciento.farm.devicemanager.service.TenantConfigService;
import com.googlecode.jsonrpc4j.spring.AutoJsonRpcServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static cn.sciento.farm.devicemanager.common.util.ReturnUtil.getReturnMap;

@Service
@AutoJsonRpcServiceImpl
public class TenantConfigJsonApiImpl implements TenantConfigJsonApi {

    @Autowired
    private TenantConfigService tenantConfigService;

    @Override
    public ResponseMessage update(TenantConfig tenantConfig) {
        int count = tenantConfigService.update(tenantConfig);
        return getReturnMap(ResultConstant.SUCCESS,count);
    }

    @Override
    public ResponseMessage get() {
        TenantConfig tenantConfig = tenantConfigService.get(null);
        return getReturnMap(ResultConstant.SUCCESS,tenantConfig);
    }
}
